package stream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Hongliang Zhu
 * @create 2021-08-01 16:41
 */
public class Demo12 {
    public static void main(String[] args) {

        String[] arr1 = { "a", "b", "c", "d" };
        String[] arr2 = { "d", "e", "f", "g" };

        Stream<String> stream1 = Stream.of(arr1);
        Stream<String> stream2 = Stream.of(arr2);

        // concat
        List<String> collect = Stream.concat(stream1, stream2).distinct().collect(Collectors.toList());
        System.out.println(collect);

        // limit
        List<Integer> collect1 = Stream.iterate(1, x -> x + 2).limit(10).collect(Collectors.toList());
        System.out.println(collect1);

        // skip跳过前n个数据
        List<Integer> collect2 = Stream.iterate(1, x -> x + 2).skip(1).limit(5).collect(Collectors.toList());
        System.out.println(collect2);


    }
}
